// 确保FDUI对象可用
import '@admin/utils/const.js'
import '@admin/utils/formhelper.js'

export default {
  data() {
    return {
      treeNodeKey: '',
      filter: {}, // 筛选条件
      queryRows: {
        'fields': []
      },
      searchType: 'normal', // 搜索类型 normal|fullsearch
      searchText: ''
    }
  },
  methods: {
    renderFiler() {
      // 设置左侧树的筛选条件filterDisplay：0左侧树【在客户端宏变量实现】
      // 获取布局和字段
      const fields = this.search.fieldInfo || []
      const tableFilterLayout = this.search.filter || []
      const prettyFields = FDUI.createTableFilter(tableFilterLayout, fields, this.filter)
      const labelWidth = FDUI.getExactLableWidth(prettyFields)
      this.queryRows = {
        'fields': prettyFields,
        'labelWidth': labelWidth
      }
      if (this.$refs.tableFilter && typeof this.$refs.tableFilter.onRendered === 'function') {
        this.$refs.tableFilter.onRendered()
      }
    }
  },
  beforeMount: function () {
    this.renderFiler()
  }
}
